<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>h5进度条</title>
    <style>
        /* 进度条容器样式 */
        .progress-container{
            width: 100%;
            background-color: pink;
            border-radius: 5px;
            overflow: hidden;
        }
        .progress-bar{
            width: 0%;
            height: 30px;
            background-color: burlywood;
            text-align: center;
            line-height: 30px;
            color: white;
            border-radius: 5px;
            /* 过渡 */
            /* transition: width .5s ease-in-out; */
        }
    </style>
</head>

<body>
    <!-- 进度条容器 -->
    <div class="progress-container">
        <!-- 进度条 -->
        <div class="progress-bar" id="myProgressBar">0%</div>
    </div>

    <!-- 开始按钮 -->
     <button onclick="startProgress()">开始</button>
    <script>
        function startProgress() {
            let width = 50;
            // 每隔100毫秒更新一次进度条
            // let timer = setInterval(() => {
            //     if (width>=100) {
            //         clearInterval(timer)

            //     } else {
                    // width++;
                    let progressBar = document.getElementById("myProgressBar")
                    progressBar.style.width = width + "%";
                    progressBar.textContent = width + "%";
            //     }
            // }, 100);
        }

    </script>
</body>
</html>